//
// Created by guanyicheng on 2021/11/8.
//

#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

bool isLetter(char &c) {
    int a = 'a', z = 'z', A = 'A', Z = 'Z';
    return (c >= a && c <= z) || (c >= A && c <= Z);
}

void wordRev(string &str) {

    reverse(str.begin(), str.end());
    int h = -1, curr = 0;
    while (curr < str.size()) {
        if (!isLetter(str[curr])) {
            str[curr] = ' ';
            reverse(str.begin() + h + 1, str.begin() + curr);
            h = curr;
        }
        ++curr;
    }
    if (isLetter(str[curr - 1])) {
        reverse(str.begin() + h + 1, str.begin() + curr);
    }
}

int main() {

    string in;
    getline(cin, in);
    wordRev(in);
    cout << in << endl;
}